<html>
<body>
<head>
    <title>	My Calendar </title>
    
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>    
<?php
include_once("php/dbconfig.php");

//$sql = 'SELECT * FROM amcnn_menu_links WHERE mlid=543';
//$sql = "select * from amcnn_node";
$sql ="CREATE PROCEDURE  prcd_prepareIntegrateionCSData()";
$sql .= "BEGIN ";

//$sql .="INSERT INTO `amcnn_node`(`nid`,`vid`,`type`,`language`,`title`,`uid`,`status`,`created`,
//`changed`,`comment`,`promote`,`moderate`,`sticky`,`tnid`,`translate`) VALUES
//('66','66','page','','Event&Activities',1,1,'1295110007',1300075397,0,1,0,0,0,0);";
//
//$sql .= "INSERT INTO `amcnn_node_revisions`(`nid`,`vid`,`uid`,`title`,`body`,`teaser`,
//`log`,`timestamp`,`format`) VALUES 
//('66','66','1','Event&Activities','<script type=\"text/javascript\">$(\"#columns\").hide();$(\"#header-region\").hide();$(\"#slider_menu_container\").after(\"<div id=''wdCalendar''><iframe src=''/calendarservice/index.php'' width=''100%'' height=''500''></iframe></div>\");</script>',
//'','','1306312350','3');";
//UPDATE `amcnnc5_dev_amcnn`.`amcnn_node_revisions` SET `body`='<script type=\"text/javascript\">$(\"#columns\").hide();$(\"#header-region\").hide();$(\"#slider_menu_container\").after(\"<div id=\'wdCalendar\'><iframe src=\'/calendarservice/index.php\' width=\'100%\' height=\'800\'></iframe></div>\");</script>' WHERE `vid`='66';

//$sql .="UPDATE amcnn_menu_links SET link_path='http://dev.amcnn.com/node/66' WHERE mlid=543;";

//$sql .="INSERT INTO `amcnn_users_roles` (`uid`,`rid`) VALUES
//('1','3');";

//$sql .= "DELETE FROM amcnn_cache;
//DELETE FROM amcnn_cache_block;
//DELETE FROM amcnn_cache_content;
//DELETE FROM amcnn_cache_filter;
//DELETE FROM amcnn_cache_form;
//DELETE FROM amcnn_cache_menu;
//DELETE FROM amcnn_cache_page;
//DELETE FROM amcnn_cache_update;
//DELETE FROM amcnn_cache_views;
//DELETE FROM amcnn_cache_views_data;";

//$sql .= "UPDATE `event_type` SET `color_mark`='#E1F7EE' WHERE `name_zh_hk`='展覽';
//
//UPDATE `event_type` SET `color_mark`='#EAFAFF' WHERE `name_zh_hk`='電影';
//
//UPDATE `event_type` SET `color_mark`='#FFFDC5' WHERE `name_zh_hk`='音樂';
//
//UPDATE `event_type` SET `color_mark`='#FFECE3' WHERE `name_zh_hk`='舞蹈';
//
//UPDATE `event_type` SET `color_mark`='#ECEBFF' WHERE `name_zh_hk`='中國戲曲';
//
//UPDATE `event_type` SET `color_mark`='#FFE5FE' WHERE `name_zh_hk`='綜合藝術';
//
//UPDATE `event_type` SET `color_mark`='#F6EDD8' WHERE `name_zh_hk`='工作坊';
//
//UPDATE `event_type` SET `color_mark`='#E8F8BD' WHERE `name_zh_hk`='合家歡';
//
//UPDATE `event_type` SET `color_mark`='#FFEABE' WHERE `name_zh_hk`='戲劇';";



$sql .= "DROP TABLE IF EXISTS `cs_parameter`;

CREATE TABLE `cs_parameter` (
  `parameter_code` varchar(150) NOT NULL,
  `parameter_value` varchar(150) DEFAULT NULL,
  `description` varchar(250) DEFAULT NULL,
  PRIMARY KEY (`parameter_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

insert  into `cs_parameter`(`parameter_code`,`parameter_value`,`description`) values 
('dbTablePrefix','amcnn_','數據表的前綴'),('defaultTime','23:59:58','默認的Event結束時間'),
('downloadPath','/calendarservice/download/excel/','導出文件的臨時存放位置'),
('flashBrowerFileType','application/x-shockwave-flash','Flash文件在不同瀏覽器的文件類型，用逗號分隔'),
('flashExtName','swf','Flash文件的擴展名'),
('flashFileSize','1000','可上傳的文件大小(KB)'),
('flashUploadPath','/calendarservice/upload','Flash上傳後保存的位置'),
('homePage','/user','無權限登錄返回的頁面'),
('imgUploadPath','/calendarservice/upload','廣告圖片上傳後存放的位置'),
('pageSize','10','分頁顯示時每頁顯示多少行'),
('pictureBrowerFileType','image/jpeg','圖片在不同瀏覽器下對應的文件類型，用逗號分隔'),
('pictureExtName','jpg,jpeg,png','可上傳圖片的擴展名,用逗號分隔'),
('pic_ad_fileSize','300','可上傳的文件大小(KB)'),
('pic_big_height','450','大型廣告圖片的高'),
('pic_big_width','680','大型廣告圖片的寬'),
('pic_median_height','400','中型廣告圖片的高'),
('pic_median_width','550','中型廣告圖片的寬'),
('pic_small_height','160','小廣告圖片的高'),
('pic_small_width','120','小廣告圖片的寬'),
('uploadFileSize','300','可上傳的文件大小(KB)'),
('uploadPath','/calendarservice/upload/excel','導入文件的臨時存放位置'),
('xNumberDays','60','前後多少天');";


//$sql .= "DELETE FROM amcnn_cache;
//DELETE FROM amcnn_cache_block;
//DELETE FROM amcnn_cache_content;
//DELETE FROM amcnn_cache_filter;
//DELETE FROM amcnn_cache_form;
//DELETE FROM amcnn_cache_menu;
//DELETE FROM amcnn_cache_page;
//DELETE FROM amcnn_cache_update;
//DELETE FROM amcnn_cache_views;
//DELETE FROM amcnn_cache_views_data;";


//$sql .= "DROP TABLE IF EXISTS `event`;
//CREATE TABLE `event` (
//  `eid` int(11) unsigned NOT NULL AUTO_INCREMENT,
//  `festival` varchar(150) DEFAULT NULL,
//  `subject` varchar(200) NOT NULL,
//  `description` varchar(500) DEFAULT NULL,
//  `start_time` datetime DEFAULT NULL,
//  `end_time` datetime DEFAULT NULL,
//  `last_update_time` datetime DEFAULT NULL,
//  `is_allday_event` smallint(6) NOT NULL,
//  `color` varchar(10) DEFAULT NULL,
//  `recurring_rule` varchar(500) DEFAULT NULL,
//  `detail_url` varchar(250) DEFAULT NULL,
//  `picture_paths` varchar(250) DEFAULT NULL,
//  `flash_paths` varchar(250) DEFAULT NULL,
//  `delete_flag` int(11) DEFAULT NULL,
//  `etid` int(11) unsigned NOT NULL COMMENT 'Refence to event_type id',
//  `vid` int(11) unsigned NOT NULL COMMENT 'Refence to venue id',
//  `uid` int(10) unsigned DEFAULT NULL COMMENT 'Refence to drupal uses id',
//  PRIMARY KEY (`eid`),
//  KEY `etid` (`etid`),
//  KEY `vid` (`vid`),
//  KEY `uid` (`uid`)
//) ENGINE=MyISAM AUTO_INCREMENT=442 DEFAULT CHARSET=utf8;";


//$sql .= "UPDATE `amcnn_node_revisions` SET `body`='<script type=\"text/javascript\">$(\"#columns\").hide();$(\"#header-region\").hide();$(\"#slider_menu_container\").after(\"<div id=\'wdCalendar\' height=\'800px\'><iframe src=\'/calendarservice/index.php\' width=\'100%\' height=\'820px\' scrolling=\'no\'></iframe></div>\");</script>' WHERE `vid`='66';";

//$sql .="ALTER TABLE `event` ADD COLUMN `click_window_control` INT(10) NULL DEFAULT 0  AFTER `commercial_control` ;";

$sql.= "ALTER TABLE `event` CHANGE COLUMN `description` `description` VARCHAR(1000) NULL DEFAULT NULL  ;";

$sql .= " END";

$sqlCall = "call prcd_prepareIntegrateionCSData();";

$sqlDropProcd = "drop procedure if exists prcd_prepareIntegrateionCSData;";



try{
    
     $db = new DBConnection();
     $db->getConnection();
     
     if(mysql_query($sql) == false)
     {
//         echo '<br>Read table fail</br>';
//         echo mysql_error();
         
          echo '<br>Create procedure fail</br>';
        echo mysql_error();
     }
 else {
//         echo '<br>Read table sucessfully</br>';
//         $result = mysql_query($sql);
//         $added_nid = 0;
//         while($row = mysql_fetch_array($result)) 
//         {
//             $added_nid += 1;
//             echo '<br>'.$row[0].'</br>';
//         }
//         echo '<br>'.'NodeID: '.$added_nid.'</br>';
     echo '<br>Create procedure sucessfully</br>';
     }
     
     if(mysql_query($sqlCall) == false){
          echo '<b>Call procedure fail</b>';
         echo mysql_error();
     }  else {
         echo '<br>Call procedure sucessfully</br>';
     }
     
     if(mysql_query($sqlDropProcd) == false){
          echo '<br>Drop procedure fail</br>';
         echo mysql_error();
     }  else {
          echo '<br>Drop procedure sucessfully</br>';
     }
    
}catch(Exception $e)
{
    $e->getMessage();
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
</body>
</html>